package torres.item;

import java.io.Serializable;

import torres.entity.Entity;

/**
 * @author Torres
 * Represents a base Item, providing a skeleton for the
 * specific kinds of items.
 */
@SuppressWarnings("serial")
public abstract class Item implements Serializable
{
	private String name;
	private boolean consumed;
	protected String asciiRep;
	
	/**
	 * Triggers the effect of an Entity walking on this item.
	 * @param e The Entity that is walking on this item
	 */
	public abstract void onTouch(Entity e);
	
	/**
	 * Returns the name of the item.
	 * @return The name of the item.
	 */
	protected String getName() {
		
		return this.name;
	}
	
	/**
	 * Set the name of the item to the specified name.
	 * @param The new name of the item.
	 */
	protected void setName(String name) {
		
		this.name = name;
	}
	
	/**
	 * Returns the ASCII representation of the item.
	 * @return The ASCII representation of the item.
	 */
	public String getAsciiRep() {
		
		return this.asciiRep;
	}
	
	/**
	 * Sets the ASCII representation to the specified String.
	 * @param asciiRep The representation to be used in the ASCII viewport
	 */
	protected void setAsciiRep(String asciiRep) {
		
		this.asciiRep = asciiRep;
	}

	/**
	 * Get the name of the image associated with this Item.
	 * @return The name of the image. Equivalent to this.getName() + ".png".
	 */
	public String getImageName() {
		return this.getName() + ".png";
	}

	/** 
	 * Tests to see if this item is an Obstacle.
	 * @return True if this item is an Obstacle, false otherwise.
	 */
	public boolean isObstacle() {
		
		return false;
	}
	
	/**
	 * Tests to see if this item is a Trap.
	 * @return True if this item is a Trap, false otherwise.
	 */
	public boolean isTrap() {
		return false;
	}
	
	/**
	 * Returns the String representation of this Item.
	 * @return The String representation of this Item.
	 */
	@Override
	public String toString() {
		
		return this.getName();
	}
	
	
	/**
	 * Tests to see if this Item is equivalent to the specified Item.
	 * @param The item to be tested for equality.
	 * @return True if this Item has the same name as the specified Item.
	 */
	public boolean equals(Item item) {
		return this.getName().equals(item.getName());
	}

	/**
	 * Sets the consumer flag of this item to the specified boolean.
	 * @param consumed The new value of consumed.
	 */
	public void setConsumed(boolean consumed) {
		
		this.consumed = consumed;
	}

	/**
	 * Tests to see if this item was consumed.
	 * @return True if this Item was consumed on last touch, false otherwise.
	 */
	public boolean isConsumed() {
		
		return consumed;
	}
	
	public String getToolTip() {
		return "SHOULDN'T BE PRINTING TOOL TIP!";
	}
}
